<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>选择申请表</title>
    <link rel="stylesheet" href="../../dist/css/layui.css">

</head>
<body>
<form class="layui-form">
    <div class="layui-form-item" style="width: 300px">
        <div class="layui-input-block">
            <input type="text" name="id" value='${param.id}' hidden>
        </div>
    </div>
    <!-- 电话 -->
    <div class="layui-form-item" style="width: 300px">
        <label class="layui-form-label">电话:</label>
        <div class="layui-input-block">
            <input type="text" name="phone" required  lay-verify="phone" placeholder="请输入电话号码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <!-- 邮箱 -->
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱:</label>
        <div class="layui-input-inline">
            <input type="text" name="email" required lay-verify="email" placeholder="name@example.com" autocomplete="off" class="layui-input">
        </div>
    </div>

    <!-- 政治面貌，单选框 -->
    <div class="layui-form-item">
        <label class="layui-form-label">政治面貌:</label>
        <div class="layui-input-block">
            <select name="politicalStatus" lay-verify="required">
                <option value=""></option>
                <option value="共产党员">共产党员</option>
                <option value="预备党员">预备党员</option>
                <option value="共青团员">共青团员</option>
                <option value="群众">群众</option>
            </select>
        </div>
    </div>

    <!-- 是否为贫困生，单选框 -->
        <div class="layui-form-item">
            <label class="layui-form-label">是否贫困生:</label>
            <div class="layui-input-block">
                <input type="radio" name="needyStudent" value="1" title="是">
                <input type="radio" name="needyStudent" value="0" title="否" checked>
            </div>
        </div>
    <!-- 寝室号 -->
    <div class="layui-form-item">
        <label class="layui-form-label">寝室号:</label>
        <div class="layui-input-inline">
            <input type="text" name="dorm" lay-verify="required" placeholder="例如：西和2幢518" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!-- 个人特长 -->
    <div class="layui-form-item">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">个人特长:</label>
            <div class="layui-input-block">
                <textarea name="strength" placeholder="请输入内容" class="layui-textarea" lay-verify="required"></textarea>
            </div>
        </div>
    </div>
    <!-- 空闲时间，复选框 -->
    <div class="layui-form-item">
        <label class="layui-form-label">空闲时间:</label>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="MON1" title="周一1">
            <input type="checkbox" name="freeTime" value="MON2" title="周一2">
            <input type="checkbox" name="freeTime" value="MON3" title="周一3">
            <input type="checkbox" name="freeTime" value="MON4" title="周一4">
            <input type="checkbox" name="freeTime" value="MON5" title="周一5">
            <input type="checkbox" name="freeTime" value="MON6" title="周一6">
            <input type="checkbox" name="freeTime" value="MON7" title="周一7">
            <input type="checkbox" name="freeTime" value="MON8" title="周一8">
            <input type="checkbox" name="freeTime" value="MON9" title="周一9">
            <input type="checkbox" name="freeTime" value="MON10" title="周一10">
            <input type="checkbox" name="freeTime" value="MON11" title="周一11">
            <input type="checkbox" name="freeTime" value="MON12" title="周一12">
        </div>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="TUE1" title="周二1">
            <input type="checkbox" name="freeTime" value="TUE2" title="周二2">
            <input type="checkbox" name="freeTime" value="TUE3" title="周二3">
            <input type="checkbox" name="freeTime" value="TUE4" title="周二4">
            <input type="checkbox" name="freeTime" value="TUE5" title="周二5">
            <input type="checkbox" name="freeTime" value="TUE6" title="周二6">
            <input type="checkbox" name="freeTime" value="TUE7" title="周二7">
            <input type="checkbox" name="freeTime" value="TUE8" title="周二8">
            <input type="checkbox" name="freeTime" value="TUE9" title="周二9">
            <input type="checkbox" name="freeTime" value="TUE10" title="周二10">
            <input type="checkbox" name="freeTime" value="TUE11" title="周二11">
            <input type="checkbox" name="freeTime" value="TUE12" title="周二12">
        </div>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="WED1" title="周三1">
            <input type="checkbox" name="freeTime" value="WED2" title="周三2">
            <input type="checkbox" name="freeTime" value="WED3" title="周三3">
            <input type="checkbox" name="freeTime" value="WED4" title="周三4">
            <input type="checkbox" name="freeTime" value="WED5" title="周三5">
            <input type="checkbox" name="freeTime" value="WED6" title="周三6">
            <input type="checkbox" name="freeTime" value="WED7" title="周三7">
            <input type="checkbox" name="freeTime" value="WED8" title="周三8">
            <input type="checkbox" name="freeTime" value="WED9" title="周三9">
            <input type="checkbox" name="freeTime" value="WED10" title="周三10">
            <input type="checkbox" name="freeTime" value="WED11" title="周三11">
            <input type="checkbox" name="freeTime" value="WED12" title="周三12">
        </div>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="THU1" title="周四1">
            <input type="checkbox" name="freeTime" value="THU2" title="周四2">
            <input type="checkbox" name="freeTime" value="THU3" title="周四3">
            <input type="checkbox" name="freeTime" value="THU4" title="周四4">
            <input type="checkbox" name="freeTime" value="THU5" title="周四5">
            <input type="checkbox" name="freeTime" value="THU6" title="周四6">
            <input type="checkbox" name="freeTime" value="THU7" title="周四7">
            <input type="checkbox" name="freeTime" value="THU8" title="周四8">
            <input type="checkbox" name="freeTime" value="THU9" title="周四9">
            <input type="checkbox" name="freeTime" value="THU10" title="周四10">
            <input type="checkbox" name="freeTime" value="THU11" title="周四11">
            <input type="checkbox" name="freeTime" value="THU12" title="周四12">
        </div>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="FRI1" title="周五1">
            <input type="checkbox" name="freeTime" value="FRI2" title="周五2">
            <input type="checkbox" name="freeTime" value="FRI3" title="周五3">
            <input type="checkbox" name="freeTime" value="FRI4" title="周五4">
            <input type="checkbox" name="freeTime" value="FRI5" title="周五5">
            <input type="checkbox" name="freeTime" value="FRI6" title="周五6">
            <input type="checkbox" name="freeTime" value="FRI7" title="周五7">
            <input type="checkbox" name="freeTime" value="FRI8" title="周五8">
            <input type="checkbox" name="freeTime" value="FRI9" title="周五9">
            <input type="checkbox" name="freeTime" value="FRI10" title="周五10">
            <input type="checkbox" name="freeTime" value="FRI11" title="周五11">
            <input type="checkbox" name="freeTime" value="FRI12" title="周五12">
        </div>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="SAT1" title="周六1">
            <input type="checkbox" name="freeTime" value="SAT2" title="周六2">
            <input type="checkbox" name="freeTime" value="SAT3" title="周六3">
            <input type="checkbox" name="freeTime" value="SAT4" title="周六4">
            <input type="checkbox" name="freeTime" value="SAT5" title="周六5">
            <input type="checkbox" name="freeTime" value="SAT6" title="周六6">
            <input type="checkbox" name="freeTime" value="SAT7" title="周六7">
            <input type="checkbox" name="freeTime" value="SAT8" title="周六8">
            <input type="checkbox" name="freeTime" value="SAT9" title="周六9">
            <input type="checkbox" name="freeTime" value="SAT10" title="周六10">
            <input type="checkbox" name="freeTime" value="SAT11" title="周六11">
            <input type="checkbox" name="freeTime" value="SAT12" title="周六12">
        </div>
        <div class="layui-input-block">
            <input type="checkbox" name="freeTime" value="SUN1" title="周日1">
            <input type="checkbox" name="freeTime" value="SUN2" title="周日2">
            <input type="checkbox" name="freeTime" value="SUN3" title="周日3">
            <input type="checkbox" name="freeTime" value="SUN4" title="周日4">
            <input type="checkbox" name="freeTime" value="SUN5" title="周日5">
            <input type="checkbox" name="freeTime" value="SUN6" title="周日6">
            <input type="checkbox" name="freeTime" value="SUN7" title="周日7">
            <input type="checkbox" name="freeTime" value="SUN8" title="周日8">
            <input type="checkbox" name="freeTime" value="SUN9" title="周日9">
            <input type="checkbox" name="freeTime" value="SUN10" title="周日10">
            <input type="checkbox" name="freeTime" value="SUN11" title="周日11">
            <input type="checkbox" name="freeTime" value="SUN12" title="周日12">
        </div>
        <!-- 提交 -->
        <div style="margin-top: 30px">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal layui-block" lay-submit hidden="">提交</button>
            </div>
        </div>
    </div>
</form>

<script src="../../dist/layui.js"></script>
<script>
    layui.use(['layer', 'form'], function(){
        var layer = layui.layer
            ,form = layui.form
            ,$ = layui.jquery;

        form.on('submit()',function(data){

            // 复选框内容转数组转字符串
            var arr = [];
            $("input:checkbox[name='freeTime']:checked").each(function(i){
                arr[i] = $(this).val();
            });
            data.field.freeTime = arr.join(",");//将数组合并成字符串

            $.ajax({
                url:'/student/applyWork',
                async: false,
                type:'post',
                data:data.field,
                // 是否使用传统的方式浅层序列化,若有数组参数或对象参数需要设置true
                traditional: true,
                dataType:'JSON',
                success:function(result){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    // 关闭父级弹出层
                    parent.layer.close(index);
                    parent.parent.layer.msg("申请成功！请等待审批",{icon:1,time:1000});
                    // 刷新父页面
                    parent.location.reload();

                }
            });
            return false;//组织表单默认提交并跳转
        });

    });
</script>
</body>
</html>
